﻿// <copyright file="DoxygenLauncher.cs" company="Horiba Medical">
//     Copyright (c) Horiba Medical. All rights reserved.
// </copyright>
// <summary>
//     Doxygen launcher.
// </summary>

namespace DoxyOutParser.Launcher
{
	using System.Diagnostics;

	/// <summary>
	/// Launches Doxygen with the appropriate options.
	/// </summary>
	internal class DoxygenLauncher
	{
		/// <summary>
		/// Prevents a default instance of the DoxygenLauncher class from being created.
		/// </summary>
		private DoxygenLauncher()
		{
		}

		/// <summary>
		/// Launches Doxygen with the appropriate arguments.
		/// </summary>
		/// <param name="doxyfileName">Name of the doxyfile to provide to Doxygen.</param>
		/// <param name="workingDirectoryPath">The directory where Doxygen should work its documentation process.</param>
		/// <param name="doxygenBinary">The path an name of the Doxygen binary.</param>
		public static void Launch(string doxyfileName, string workingDirectoryPath, string doxygenBinary)
		{
			ProcessStartInfo startInfo = new ProcessStartInfo();

			startInfo.FileName = doxygenBinary;
			startInfo.WorkingDirectory = workingDirectoryPath;
			startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
			startInfo.UseShellExecute = false;
			startInfo.CreateNoWindow = false;
			startInfo.Arguments = doxyfileName;

			try
			{
				Process listFiles = Process.Start(startInfo);

				while (!listFiles.HasExited)
				{
				}
			}
			catch
			{
				throw;
			}
		}
	}
}
